<?php

declare(strict_types=1);

namespace App\Fastapp\Model;

use Hyperf\Database\Model\Relations\HasOne;
use Mine\MineModel;

/**
 * @property int $id 主键
 * @property int $related_type 类型1微信公众号2微信小程序3微信登录
 * @property string $unique_code 三方唯一标识码
 * @property int $user_id 用户id
 * @property int $account_type
 * @property-read null|Account $account
 */
class AccountOtherRelated extends MineModel
{
    public bool $timestamps = false;

    const TYPE_WECHAT_OFFICIAL = 1;
    const TYPE_WECHAT_MINI = 2;
    const TYPE_WECHAT_APP = 3;
    const TYPE_TELEGRAM = 4;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'account_other_related';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'related_type', 'unique_code', 'user_id', 'account_type'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'related_type' => 'integer', 'user_id' => 'integer', 'account_type' => 'integer'];

    public function account(): HasOne
    {
        return $this->hasOne(Account::class, 'gene_id', 'user_id');
    }
}
